package com.rq.base.ui;

import android.content.Context;
import android.content.DialogInterface;
import android.view.View;

import com.rq.base.R;
import com.rq.base.ui.common.CommonDialog;


/**
 * Created by RaoQian on 2022/4/25.
 */
class DialogHelper {

    public interface OnDialogConfirmListener {

        void onSure();

        void onCancel();
    }

    public static void showRemind(Context context, String content,
                                  final OnDialogConfirmListener listener) {
        showRemind(context, content, listener, true);
    }

    public static void showRemind(Context context, String content,
                                  final OnDialogConfirmListener listener, boolean cancelable) {
        final CommonDialog dialog = new CommonDialog(context, content, R.layout.dialog_common_net) {
            @Override
            protected void initView(View view) {
                super.initView(view);
            }
        };
        dialog.setCancelable(cancelable);
        dialog.setSizeRate(.78F, 0F);
        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                if (listener != null) listener.onCancel();
            }
        });
        dialog.setClickListener(new CommonDialog.OnConfirmClickListener() {
            @Override
            public void onClickConfirm(boolean isConfirm, Object data) {
                dialog.dismiss();
                if (listener != null) {
                    if (isConfirm) {
                        listener.onSure();
                    } else {
                        listener.onCancel();
                    }
                }
            }
        });
        dialog.show();
    }

}
